<?php

namespace App\Models;

use App\MongoModel as Model;
use App\Plugins\Plugin;
use Jenssegers\Mongodb\Eloquent\SoftDeletes;

/**
 * Class Company
 * @package App\Models
 * @property string $id
 * @property string $name
 */
class Company extends Model
{
    use softDeletes;
    public $timestamps = false;

    protected $fillable = [
        'name',
    ];

    public function getPluginAttribute()
    {
        if (isset($this->options)) {
            $plugins = array_get($this->options, 'plugins', '');
            $pluginName = is_array($plugins) ? implode(',', $plugins) : $plugins;
            $plugin = (new Plugin)->pluginInfo($pluginName);
            if ($plugin) {
                $plugin->name = $pluginName;
            }
            return $plugin;
        }
        return null;
    }
    
}
